﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using XJay.Identity.IService;
using XJay.Identity.Model.Enums;
using XJay.Identity.Model.User.Export;
using XJay.Identity.Model.User.Import;

namespace XJay.Identity.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly IUserServer _userServer;

        public UserController(IUserServer userServer)
        {
            this._userServer = userServer;
        }
        /// <summary>
        /// 获取token
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<UserDto> GetToken(LoginParam param)
        {
            return await _userServer.LoginAsync(param);
        }

        /// <summary>
        /// 鉴权接口
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Authorize(Policy = PolicyType.XJayAuth)]
        public bool Authentication()
        {
            return true;
        }
        /// <summary>
        /// 鉴权接口2
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Authorize(Policy = PolicyType.XJayAuth2)]
        public bool Authentication2()
        {
            return true;
        }
        /// <summary>
        /// 鉴权接口3
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [Authorize()]
        public bool Authentication3()
        {
            return true;
        }
    }
}
